class Solution {
public:
	int rob(vector<int>& nums) {
		int _size = nums.size();
		if (_size < 2) return _size ? nums[0] : 0;
		return max(robber(nums, 0, _size - 2), robber(nums, 1, _size - 1));
	}
	int robber(vector<int>& nums, int l, int r) {
		int pre = 0, cur = 0;
		for (int i = l; i <= r; i++) {
			int temp = max(pre + nums[i], cur);
			pre = cur;
			cur = temp;
		}
		return cur;
	}
};